const Controller = require("egg").Controller;

class BaseController extends Controller {
  success(data = null, message = null, code = 20000) {
    const { ctx } = this;

    ctx.status = 200;

    ctx.body = {
      code,
      message,
      data,
      success: true,
    };
  }

  fail(message = "系统数据，不能修改或删除", code = 20001, data = null) {
    const { ctx } = this;

    ctx.status = 200;

    ctx.body = {
      code,
      message,
      data,
      success: false,
    };
  }
}
module.exports = BaseController;
